package ooday03;

import ooday03.animal.*;

public class PolymorphicDome {
    public static void main(String[] args) {
        /*Master master = new Master();
        Dog dog = new Dog("a",1,"12");
        Chick chick = new Chick("a",1,"12");
        Flsh flsh = new Flsh("a",1,"12");

        master.feed(dog);
        master.feed(chick);
        master.feed(flsh);*/

        Animal[] animals = new Animal[4];
        animals[0] = new Dog("小狗",2,"黑");
        animals[1] = new Chick("小鸡",1,"黄");
        animals[2] = new Flsh("小鱼",3,"灰");
        animals[3] = new Dog("小狗",4,"黑");

        for (int i=0;i<animals.length;i++){
            System.out.println(animals[i].name);
            animals[i].eat();
            animals[i].drink();

            if(animals[i] instanceof Dog){
                Dog dog = (Dog)animals[i];
                dog.lookHome();
            }


            if(animals[i] instanceof Chick){
                Chick chick = (Chick) animals[i];
                chick.layEggs();
            }

            if(animals[i] instanceof Swim){
                Swim swim = (Swim) animals[i];
                swim.swim();
            }
        }

        /*Animal animal = new Dog("小狗",2,"黑");
        Dog dog = (Dog) animal;
        Swim swim = (Swim) animal;

        if(animal instanceof Flsh){
            Flsh f= (Flsh) animal;
        }
          */





    }
}
